<?php
     /*
    3 // OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
    4 // all the essential functionalities required for any enterprise.
    5 // Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
    6 
    7 // OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
    8 // the GNU General Public License as published by the Free Software Foundation; either
    9 // version 2 of the License, or (at your option) any later version.
   10 
   11 // OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
   12 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   13 // See the GNU General Public License for more details.
   14 
   15 // You should have received a copy of the GNU General Public License along with this program;
   16 // if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   17 // Boston, MA  02110-1301, USA
    */
    
    class LogFileWriterLdap {
    
    
    	public static function writeLogLdap($exceptionString) {
    
    		$filename = dirname(__FILE__).'/../../lib/logs/ldapLog.txt';
    
    	    if (!($handle = fopen($filename, 'a+')))
    			return false;
    
    	    if (!fwrite($handle, $exceptionString))
    			return false;
    
        	fclose($handle);
    
    	}
    
    	public static function logLdapError($message, $userName, $ldapConnection){
    
           	$today = date("F j, Y, g:i a");
    		$logMessage = $today . ' ' . ":\n  ".$message." with user name: $userName (LDAP Error: ".ldap_errno($ldapConnection)." - ".ldap_error($ldapConnection).")\n";
    		LogFileWriterLdap::writeLogLdap($logMessage);
    	}
    
    }
    
    
    ?>
